<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>工作台</title>
    <link rel="stylesheet" href="/assets/libs/layui/css/layui.css"/>
    <link rel="stylesheet" href="/assets/module/admin.css?v=316"/>
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
    <style>
        /** 应用快捷块样式 */
        .console-app-group {
            padding: 16px;
            border-radius: 4px;
            text-align: center;
            background-color: #fff;
            cursor: pointer;
        }

        .console-app-group .console-app-icon {
            width: 32px;
            height: 32px;
            line-height: 32px;
            margin-bottom: 6px;
            display: inline-block;
            -webkit-box-sizing: border-box;
            -moz-box-sizing: border-box;
            box-sizing: border-box;
            font-size: 32px;
            color: #69c0ff;
        }

        .console-app-group:hover {
            box-shadow: 0 0 15px rgba(0, 0, 0, .08);
        }

        /** //应用快捷块样式 */

        /** 小组成员 */
        .console-user-group {
            position: relative;
            padding: 10px 0 10px 60px;
        }

        .console-user-group .console-user-group-head {
            width: 32px;
            height: 32px;
            position: absolute;
            top: 50%;
            left: 12px;
            margin-top: -16px;
        }

        .console-user-group .layui-badge {
            position: absolute;
            top: 50%;
            right: 8px;
            margin-top: -10px;
        }

        .console-user-group .console-user-group-name {
            line-height: 1.2;
        }

        .console-user-group .console-user-group-desc {
            color: #8c8c8c;
            line-height: 1;
            font-size: 12px;
            margin-top: 5px;
        }

        /** 卡片轮播图样式 */
        .admin-carousel .layui-carousel-ind {
            position: absolute;
            top: -41px;
            text-align: right;
        }

        .admin-carousel .layui-carousel-ind ul {
            background: 0 0;
        }

        .admin-carousel .layui-carousel-ind li {
            background-color: #e2e2e2;
        }

        .admin-carousel .layui-carousel-ind li.layui-this {
            background-color: #999;
        }

        /** 广告位轮播图 */
        .admin-news .layui-carousel-ind {
            height: 45px;
        }

        .admin-news a {
            display: block;
            line-height: 60px;
            text-align: center;
            border-radius: 4px;
        }
    </style>
</head>
<body>
<!-- 正文开始 -->
<div class="layui-fluid ew-console-wrapper">
    <div class="layui-row layui-col-space15">

        <div class="layui-col-xs12 layui-col-sm3 layui-col-md3">
            <div class="layui-card">
                <div class="layui-card-header">
                    我的投诉
                    <span class="icon-text pull-right" lay-tips="我的投诉" lay-direction="4" lay-offset="5px,5px">
                        <i class="layui-icon layui-icon-tips"></i>
                    </span>
                </div>
                <div class="layui-card-body">
                    <p class="lay-big-font">[[${userTousu}]]<span style="font-size: 24px;line-height: 1;">个</span></p>
                    <p>总投诉数量<span class="pull-right">[[${tousuCount}]] 个</span></p>
                </div>
            </div>
        </div>
        <div class="layui-col-xs12 layui-col-sm3 layui-col-md3">
            <div class="layui-card">
                <div class="layui-card-header">
                    我的维修
                    <span class="icon-text pull-right" lay-tips="我的维修" lay-direction="4" lay-offset="5px,5px">
                        <i class="layui-icon layui-icon-tips"></i>
                    </span>
                </div>
                <div class="layui-card-body">
                    <p class="lay-big-font">[[${userRepair}]] <span style="font-size: 24px;line-height: 1;">个</span></p>
                    <p>总维修数量<span class="pull-right">[[${repairCount}]] 个</span></p>
                </div>
            </div>
        </div>

        <div class="layui-col-xs12 layui-col-sm3 layui-col-md3">
            <div class="layui-card">
                <div class="layui-card-header">
                    我的账单
                    <span class="icon-text pull-right" lay-tips="我的账单" lay-direction="4" lay-offset="5px,5px">
                        <i class="layui-icon layui-icon-tips"></i>
                    </span>
                </div>
                <div class="layui-card-body">
                    <p class="lay-big-font">[[${userPayment}]] <span style="font-size: 24px;line-height: 1;">个</span></p>
                    <p>总帐单数<span class="pull-right">[[${paymentCount}]] 个</span></p>
                </div>
            </div>
        </div>
        <div class="layui-col-xs12 layui-col-sm3 layui-col-md3">
            <div class="layui-card">
                <div class="layui-card-header">
                    个人信息
                    <span class="icon-text pull-right" lay-tips="个人信息" lay-direction="4" lay-offset="5px,5px">
                        <i class="layui-icon layui-icon-tips"></i>
                    </span>
                </div>
                <div class="layui-card-body">
                    <p class="lay-big-font">手机号:</p>
                    <p>[[${session.user.phone}]]<span class="pull-right"></span></p>
                </div>
            </div>
        </div>
    </div>
    <!-- 快捷方式 -->
    <div class="layui-row layui-col-space15">
        <div class="layui-col-sm6" style="padding-bottom: 0;">
            <div class="layui-row layui-col-space15">
                <div class="layui-col-xs6 layui-col-sm3">
                    <div class="console-app-group" id="newTousu">
                        <i class="console-app-icon layui-icon layui-icon-group"
                           style="font-size: 26px;padding-top: 3px;margin-right: 6px;"></i>
                        <div class="console-app-name">新投诉</div>
                    </div>
                </div>
                <div class="layui-col-xs6 layui-col-sm3">
                    <div class="console-app-group" id="newRepair">
                        <i class="console-app-icon layui-icon layui-icon-chart" style="color: #95de64;"></i>
                        <div class="console-app-name">新维修</div>
                    </div>
                </div>
                <div class="layui-col-xs6 layui-col-sm3">
                    <div class="console-app-group" id="look">
                        <i class="console-app-icon layui-icon layui-icon-cart" style="color: #95de64;"></i><span class="layui-badge-dot"></span>
                        <div class="console-app-name">看账单</div>
                    </div>
                </div>
                <div class="layui-col-xs6 layui-col-sm3">
                    <div class="console-app-group" ew-event="reset_user">
                        <i class="console-app-icon layui-icon layui-icon-password" style="color: #ff9c6e;"></i>
                        <div class="console-app-name">改密码</div>
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-col-sm6" style="padding-bottom: 0;">
            <div class="layui-card">
                <div class="layui-card-body" style="padding: 17px 15px;">
                    <div class="layui-card-body">
                        <p class="lay-big-font">[[${gonggao.title}]]</p>
                        <p>[[${gonggao.content}]]</p>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <div class="layui-row layui-col-space15">
        <div class="layui-col-lg6 layui-col-md6">
            <div class="layui-card">
                <div class="layui-card-header">我的投诉</div>
                <div class="layui-card-body" style="padding: 17px 15px;">
                    <table id="tousu1" lay-filter="tousu1"></table>
                </div>
            </div>
        </div>
        <div class="layui-col-lg6 layui-col-md6">
            <div class="layui-card">
                <div class="layui-card-header">我的维修</div>
                <div class="layui-card-body" style="padding: 17px 15px;">
                    <table id="weixiu1" lay-filter="weixiu1"></table>
                </div>
            </div>
        </div>
    </div>
</div>
<!-- 加载动画 -->
<div class="page-loading">
    <div class="ball-loader">
        <span></span><span></span><span></span><span></span>
    </div>
</div>
<script type="text/html" id="modelTousu">
    <form id="modelTousuForm" lay-filter="modelTousuForm" class="layui-form model-form">
        <input name="id" type="hidden"/>
        <div class="layui-form-item">
            <label class="layui-form-label">投诉内容</label>
            <div class="layui-input-block">
                <input name="content" placeholder="投诉内容" type="text" class="layui-input" maxlength="20"
                       lay-verType="tips" lay-verify="required" required/>
            </div>
        </div>
        <div class="layui-form-item text-right">
            <button class="layui-btn layui-btn-primary" type="button" ew-event="closePageDialog">取消</button>
            <button class="layui-btn" lay-filter="modelSubmitTousu" lay-submit>保存</button>
        </div>
    </form>
</script>
<script type="text/html" id="modelRepair">
    <form id="modelRepairForm" lay-filter="modelRepairForm" class="layui-form model-form">
        <input name="id" type="hidden"/>
        <div class="layui-form-item">
            <label class="layui-form-label">维修内容</label>
            <div class="layui-input-block">
                <input name="content" placeholder="维修内容" type="text" class="layui-input" maxlength="20"
                       lay-verType="tips" lay-verify="required" required/>
            </div>
        </div>
        <div class="layui-form-item text-right">
            <button class="layui-btn layui-btn-primary" type="button" ew-event="closePageDialog">取消</button>
            <button class="layui-btn" lay-filter="modelSubmitRepair" lay-submit>保存</button>
        </div>
    </form>
</script>
<script type="text/html" id="building_3">
    <input type="checkbox" lay-filter="ckStateUser" value="{{d.status}}" lay-skin="switch" disabled
           lay-text="已缴费|未缴费" {{d.status==1?'checked':''}}/>
</script>
<script type="text/html" id="templet2">
    {{d.user.username}}
</script>
<script type="text/html" id="templet1">
    {{d.payment.name}}
</script>
<script type="text/html" id="building_2">
    <input type="checkbox" lay-filter="ckStateUser" value="{{d.status}}" lay-skin="switch" disabled
           lay-text="已处理|未处理" {{d.status==1?'checked':''}}/>
</script>
<script type="text/html" id="building_1">
    <input type="checkbox" lay-filter="ckStateUser" value="{{d.status}}" lay-skin="switch" disabled
           lay-text="已维修|未维修" {{d.status==1?'checked':''}}/>
</script>
<!-- js部分 -->
<script type="text/javascript" src="/assets/libs/layui/layui.js"></script>
<script type="text/javascript" src="/assets/js/common.js?v=316"></script>
<script>
    layui.use(['layer', 'util', 'table', 'admin', 'form', 'tableX'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var util = layui.util;
        var admin = layui.admin;
        var form = layui.form;
        var tableX = layui.tableX;
        var table = layui.table;
        var insTb = table.render({
            elem: '#tousu1',
            url: '/api/getAllToususByUser',
            page: true,
            height: "250",
            cellMinWidth: 100,
            cols: [
                [
                    {type: 'numbers', title: 'id'}
                    ,{field: 'content', sort: true, title: '投诉内容'}
                    ,{field: 'time', sort: true,templet: function (d) {
                        return util.toDateString(d.time);
                    }, title: '发布时间'}
                    ,{field: 'result', sort: true, title: '处理结果'}
                    ,{field: 'status', sort: true, templet: '#building_2', title: '类型'}
                ]
            ]
        });
        var insTb2 = table.render({
            elem: '#weixiu1',
            url: '/api/getAllRepairsByUser',
            page: true,
            height: "250",
            cellMinWidth: 100,
            cols: [
                [
                    {type: 'numbers', title: 'id'}
                    ,{field: 'content', sort: true, title: '维修内容'}
                    ,{field: 'time', sort: true,templet: function (d) {
                        return util.toDateString(d.time);
                    }, title: '发布时间'}
                    ,{field: 'result', sort: true, title: '维修结果'}
                    ,{field: 'status', sort: true, templet: '#building_2', title: '类型'}
                ]
            ]
        });

        // 添加
        $('#newRepair').click(function () {
            admin.open({
                type: 1,
                title: '添加维修',
                content: $('#modelRepair').html(),
                success: function (layero, dIndex) {
                    $(layero).children('.layui-layer-content').css('overflow', 'visible');
                    var url = '/api/addRepair';
                    // 表单提交事件
                    form.on('submit(modelSubmitRepair)', function (data) {
                        layer.load(2);
                        $.ajax({
                            url:url,
                            type:"POST",
                            data:JSON.stringify(data.field),
                            contentType:"application/json; charset=utf-8",
                            dataType:"json",
                            success: function(res){
                                layer.closeAll('loading');
                                if (res.code == 200) {
                                    layer.close(dIndex);
                                    layer.msg(res.msg, {icon: 1});
                                    insTb2.reload({}, 'data');
                                } else {
                                    layer.msg(res.msg, {icon: 2});
                                }
                            }
                        })
                        return false;
                    });
                }
            });
        });

        $('#newTousu').click(function () {
            admin.open({
                type: 1,
                title: '添加投诉',
                content: $('#modelTousu').html(),
                success: function (layero, dIndex) {
                    $(layero).children('.layui-layer-content').css('overflow', 'visible');
                    var url = '/api/addTousu';
                    // 表单提交事件
                    form.on('submit(modelSubmitTousu)', function (data) {
                        layer.load(2);
                        $.ajax({
                            url:url,
                            type:"POST",
                            data:JSON.stringify(data.field),
                            contentType:"application/json; charset=utf-8",
                            dataType:"json",
                            success: function(res){
                                layer.closeAll('loading');
                                if (res.code == 200) {
                                    layer.close(dIndex);
                                    layer.msg(res.msg, {icon: 1});
                                    insTb.reload({}, 'data');
                                } else {
                                    layer.msg(res.msg, {icon: 2});
                                }
                            }
                        })
                        return false;
                    });
                }
            });
        });

        $('#look').click(function () {
            var $a = $('#look');
            var offset = $a.offset();
            var top = offset.top;
            var left = offset.left;
            layer.open({
                type: 1,
                title: false,
                area: '590px',
                offset: ['100px', (left - 260 + $a.outerWidth()) + 'px'],
                shade: .01,
                shadeClose: true,
                fixed: false,
                content: '<table id="lookSSXMTable" lay-filter="lookSSXMTable"></table>',
                success: function () {
                    tableX.render({
                        elem: '#lookSSXMTable',
                        url: '/api/getAllPaymentDetails',
                        page: true,
                        cols: [
                            [
                                {type: 'numbers'}
                                ,{field: 'payment', sort: true, templet: '#templet1', title: '缴费名'}
                                ,{field: 'user', sort: true, templet: '#templet2', title: '用户名'}
                                ,{field: 'value', sort: true, title: '缴费值'}
                                ,{field: 'time', sort: true, templet: function (d) {
                                    return util.toDateString(d.time);
                                },title: '缴费时间'}
                                ,{field: 'status', sort: true, templet: '#building_3', title: '状态'}
                            ]
                        ],
                        size: ''
                    });
                }
            });
        });
    });
</script>
</body>

</html>